import dao.Buyer;
import dao.NewsDao;
import dao.impl.IntermediaryImpl;
import dao.impl.IntermediarySubclass;
import dao.impl.NewsServiceImpl;
import dao.impl.RealBuyer;
import entity.News;
import factory.*;

public class Test {
    public static void main(String[] args) {
//        NewsDao dao = SimpleDaoFactory.getInstance("redis");
//        NewsServiceImpl service = new NewsServiceImpl();
//        service.setDao1(dao);
//        News news = new News();
//        dao.save(news);
//
//        AbstractFactory factory = new MySqlDaoFactory();//改变具体工厂可创建不同产品
//        NewsDao dao1 = factory.getInstance();
//        NewsServiceImpl newsService = new NewsServiceImpl();
//        newsService.setDao1(dao1);
//        News news1 = new News();
//        dao1.save(news1);
//
//
//        Buyer buyer = new IntermediaryImpl(new RealBuyer());
//        String havealook = buyer.havealook();
//        System.out.println(havealook);
//
//        RealBuyer buyer1 = new IntermediarySubclass();
//        String havealook1 = buyer1.havealook();
//
//        System.out.println(havealook1);
//
//
//
//        Buyer buyer2 = IntermediarJdkProxyFactory.create(new RealBuyer());
//        String havealook2 = buyer2.havealook();
//        System.out.println(havealook2);



        RealBuyer buyer3 = IntermediaryCglibProxyFactory.create(RealBuyer.class);
        String havealook3 = buyer3.havealook();
        System.out.println(havealook3);
    }
}
